﻿// ActionScript file
/* 
	@提供对多个（x，y）进行绘制操�?

 */
package org.nickro.graphics{
	public class Polygon extends BasicShape{
		private var xpoints:Array;
		private var ypoints:Array;
		public function Polygon(){
			super();
		}
		override protected function drawShape():void{
			this.graphics.moveTo(xpoints[0],ypoints[0]);
			for(var i:uint=1;i<xpoints.length;i++){
				this.graphics.lineTo(xpoints[i],ypoints[i]);
				if(i == xpoints.length-1){
					this.graphics.lineTo(xpoints[0],ypoints[0]);
				}
			}
		}
		protected function setPoints(newXPoints:Array,newYPoints:Array):void{
			if(newXPoints == null ||newYPoints == null){
				return
			}
			if(newXPoints.length != newYPoints.length){
				throw new Error("x,y属性必须成�?);
			}
			xpoints=newXPoints;
			ypoints=newYPoints;
		}
	}
}